<template>
  <div class="overview-mock-test">
    <h2>使用模拟数据的概览卡片</h2>
    
    <div class="overview-grid">
      <OverviewCard 
        title="总销售额" 
        :value="mockData.totalSales" 
        :growth="mockData.growthRates.salesGrowth" 
        icon="fa-dollar-sign"
        :currency="true"
      />
      
      <OverviewCard 
        title="订单数量" 
        :value="mockData.totalOrders" 
        :growth="mockData.growthRates.ordersGrowth" 
        icon="fa-shopping-bag"
      />
      
      <OverviewCard 
        title="分销商数量" 
        :value="mockData.distributorsCount" 
        :growth="mockData.growthRates.distributorsGrowth" 
        icon="fa-users"
      />
      
      <OverviewCard 
        title="客户数量" 
        :value="mockData.customersCount" 
        :growth="mockData.growthRates.customersGrowth" 
        icon="fa-user-friends"
      />
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue';
import OverviewCard from './OverviewCard.vue';
import { generateDashboardOverviewData } from '@/utils/agentMock';

// 初始化一个默认结构，保证组件在数据加载前能正确渲染
const defaultData = {
  totalSales: 0,
  totalOrders: 0,
  distributorsCount: 0,
  customersCount: 0,
  totalCommission: 0,
  pendingCommission: 0,
  growthRates: {
    salesGrowth: 0,
    ordersGrowth: 0,
    distributorsGrowth: 0,
    customersGrowth: 0,
    commissionGrowth: 0
  }
};

const mockData = ref(defaultData);

onMounted(() => {
  // 加载模拟数据
  mockData.value = generateDashboardOverviewData();
  console.log('Mock data loaded:', mockData.value);
});
</script>

<style lang="scss" scoped>
.overview-mock-test {
  padding: 24px;
  background-color: #f8f9fa;
  
  h2 {
    margin-bottom: 24px;
    font-size: 20px;
    color: #2f3542;
  }
  
  .overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
  }
}

@media (max-width: 768px) {
  .overview-mock-test {
    padding: 16px;
    
    h2 {
      font-size: 18px;
      margin-bottom: 16px;
    }
    
    .overview-grid {
      gap: 16px;
    }
  }
}
</style> 